How do I get GIS layer labels to show on a map?
For example, a country GIS layer could display the names of the countries on the map or a geology layer might print the geological regions in appropriate places etc.:
In order to have a layer display labels on the map the layer must be described appropriately in the map file. Once done, the user can turn the labelling off/on by using a control on the user interface, (typically labeled: Layer Labels: Show/Hide).
To enable this in the map file, add a suitable LABELITEM
and LABELCACHE entry to the layer and set a LABEL block in the class.
A simple example would be:
LAYER
NAME "Marine Ecological Regions of the World"
TYPE POLYGON
STATUS ON
DATA "world/ecology/meow/MEOWv2.dbf"
###############################################
# Add these entries to make labels able to be displayed
LABELITEM ECOREGION
LABELCACHE ON
###############################################
CLASS
NAME "Marine EcoSystems"
OUTLINECOLOR 33 255 33
SYMBOL 0
###########################################
# this block describes how the label should
# be drawn
LABEL
COLOR 33 33 255
SIZE medium
POSITION auto
END
###########################################
END
END
Note: The LABELITEM value refers to the field in the GIS layer that you want to display as the text for the label (e.g. CountryName or RockType). You will need to know the name of the data fields of the GIS layer you are working with and select an appropriate one.
There are a number of other options in LABEL that can change how the label displays. See http://mapserver.gis.umn.edu/docs/reference/mapfile, in particular the Label setting, for more information about customising the label display.